package designmodel.creator.abstractfactory;

public class AbstractFactoryFactory {
    public static void main(String[] args) {
        IDateBase dateBase = new Oracle();
        dateBase.getConnection().connect();
        dateBase.getCommand().command();
    }
}

/**
 * 变化：产品
 * 不变
 */
interface IConnection {
    void connect();
}

interface ICommand {
    void command();
}

interface IDateBase {
    IConnection getConnection();

    ICommand getCommand();
}

/********************下面是mySql*******************************/
class MySqlConnection implements IConnection {
    @Override
    public void connect() {
        System.out.println("mysql connection");
    }
}

class MySqlCommand implements ICommand {
    @Override
    public void command() {
        System.out.println("mysql command");
    }
}

class MySql implements IDateBase {
    @Override
    public IConnection getConnection() {
        return new MySqlConnection();
    }

    @Override
    public ICommand getCommand() {
        return new MySqlCommand();
    }
}

/************************上边是mysql，下面是oracle****************************/
class Oracle implements IDateBase {
    @Override
    public IConnection getConnection() {
        return new OracleConnection();
    }

    @Override
    public ICommand getCommand() {
        return new OracleCommand();
    }
}

class OracleConnection implements IConnection {
    @Override
    public void connect() {
        System.out.println("Oracle connection");
    }
}

class OracleCommand implements ICommand {
    @Override
    public void command() {
        System.out.println("Oracle connection");
    }
}



